home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / print / cramv33.arj / FILTER1.C < prev    next >
Text File  |  1991-10-12  |  786b  |  40 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <fcntl.h>
  5. #include <io.h>
  6.  
  7. #define    REC_SIZE 256
  8.  
  9. int     main ()
  10.  
  11. {
  12.         int     status = 0;
  13.     char     file_buf[REC_SIZE];
  14.  
  15.         status = setmode ( fileno (stdin), O_BINARY );
  16.     while ( (status = fread (file_buf, 1, REC_SIZE, stdin) ) != 0 ) {
  17.             filter_rec (file_buf, status);
  18.         };
  19.     return (0);
  20. }
  21.  
  22.  
  23. int    filter_rec (file_buf, record_size)
  24.  
  25. char      *file_buf;
  26. int     record_size;
  27. {
  28.     int    i;
  29.  
  30.     for (i = 0; i < record_size; i++) {
  31.             if (file_buf[i] == 0x0A) return 1;
  32.             if (file_buf[i] == 0x0D) {
  33.                 putc (0x0A, stdout);
  34.                 return 1;
  35.             };
  36.             putc (file_buf[i], stdout);
  37.         };
  38.         return 1;
  39. }
  40.